<template>
	<view>
		<u-modal :show="showModal" :title="`${selectedMachineItem.machineName}-运转参数`" confirmText="关闭" @confirm="onClose">
			<view class="slot-content">
				<u-loading-icon :show="detailModalLoading"></u-loading-icon>
				<u-collapse v-if="!detailModalLoading">
					<u-collapse-item title="在纺品种" icon="order" name="Docs guide">
						<u-row>
							<u-col :span="12">
								<view class="margin-bottom-10 flex-start-center">
									<view class="form-label">生产品种:</view>
									<view class="form-val">{{ machineDetailData.productName || '无' }}</view>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col :span="12">
								<view class="margin-bottom-10 flex-start-center">
									<view class="form-label">生产批号:</view>
									<view class="form-val">{{ machineDetailData.batchCode || '无' }}</view>
								</view>
							</u-col>
						</u-row>
					</u-collapse-item>
					<u-collapse-item title="工艺参数" icon="share" name="Variety components">
						<u-row>
							<u-col :span="6">
								<view class="margin-bottom-10 flex-start-center">
									<view class="form-label">设定长度:</view>
									<view class="form-val">{{ machineDetailData.settingLength || '无' }}</view>
								</view>
							</u-col>
							<u-col :span="6">
								<view class="flex-start-center">
									<view class="form-label">当前长度:</view>
									<view class="form-val">{{ machineDetailData.currentLength || '无' }}</view>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col :span="6">
								<view class="margin-bottom-10 flex-start-center">
									<view class="form-label">产量(M):</view>
									<view class="form-val">{{ machineDetailData.totalM || '无' }}</view>
								</view>
							</u-col>
							<u-col :span="6">
								<view class="flex-start-center">
									<view class="form-label">锭数:</view>
									<view class="form-val">{{ machineDetailData.spinCount || '无' }}</view>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col :span="6">
								<view class="margin-bottom-10 flex-start-center">
									<view class="form-label">牵引(伸)倍:</view>
									<view class="form-val">{{ machineDetailData.draftMultiple || '无' }}</view>
								</view>
							</u-col>
							<u-col :span="6">
								<view class="flex-start-center">
									<view class="form-label">锭速:</view>
									<view class="form-val">{{ machineDetailData.spindleSpeed || '无' }}</view>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col :span="6">
								<view class="margin-bottom-10 flex-start-center">
									<view class="form-label">前罗拉直径:</view>
									<view class="form-val">{{ machineDetailData.frontRollerDiameter || '无' }}</view>
								</view>
							</u-col>
							<u-col :span="6">
								<view class="flex-start-center">
									<view class="form-label">前罗拉转速:</view>
									<view class="form-val">{{ machineDetailData.speed || '无' }}</view>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col :span="6">
								<view class="margin-bottom-10 flex-start-center">
									<view class="form-label">前罗拉线速:</view>
									<view class="form-val">{{ machineDetailData.frontRollerLineSpeed || '无' }}</view>
								</view>
							</u-col>
							<u-col :span="6">
								<view class="flex-start-center">
									<view class="form-label">当前长度:</view>
									<view class="form-val">{{ machineDetailData.currentLength || '无' }}</view>
								</view>
							</u-col>
						</u-row>
					</u-collapse-item>
					<u-collapse-item title="能耗参数" icon="hourglass" name="Numerous tools">
						<u-row>
							<u-col :span="6">
								<view class="margin-bottom-10 flex-start-center">
									<view class="form-label">A相电流:</view>
									<view class="form-val">{{ machineDetailData.aelectricCurrent || '无' }}</view>
								</view>
							</u-col>
							<u-col :span="6">
								<view class="flex-start-center">
									<view class="form-label">B相电流:</view>
									<view class="form-val">{{ machineDetailData.belectricCurrent || '无' }}</view>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col :span="6">
								<view class="margin-bottom-10 flex-start-center">
									<view class="form-label">C相电流:</view>
									<view class="form-val">{{ machineDetailData.celectricCurrent || '无' }}</view>
								</view>
							</u-col>
							<u-col :span="6">
								<view class="flex-start-center">
									<view class="form-label">A相线电压:</view>
									<view class="form-val">{{ machineDetailData.avoltage || '无' }}</view>
								</view>
							</u-col>
						</u-row>
						<u-row>
                            <u-col :span="6">
                                <view class="flex-start-center">
                                    <view class="form-label">B相线电压:</view>
                                    <view class="form-val">{{ machineDetailData.bvoltage || '无' }}</view>
                                </view>
                            </u-col>
                            <u-col :span="6">
                                <view class="flex-start-center">
                                    <view class="form-label">C相线电压:</view>
                                    <view class="form-val">{{ machineDetailData.cvoltage || '无' }}</view>
                                </view>
                            </u-col>
						</u-row>
					</u-collapse-item>
				</u-collapse>
			</view>
		</u-modal>

	</view>
</template>

<script>
	import {
		reportMachineStateInfo
	} from "../../../../api";

	export default {
		props: {
			selectedMachineItem: {
				type: Object,
				default () {
					return {};
				}
			},
			modalState: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				machineDetailData: {},
				showModal: false,
				detailModalLoading: false,
			};
		},
		methods: {
			onClose() {
				this.$emit('on-close', false);
			},
			getMachineDetailRequest() {
				this.detailModalLoading = true;
				reportMachineStateInfo({
					machineId: this.selectedMachineItem.machineId
				}).then(res => {
					this.detailModalLoading = false;
					if (res.data.status === 200) {
						this.machineDetailData = res.data.res;
					}
				})
			},
		},
		watch: {
			modalState(newVal) {
				this.showModal = newVal;
				if (newVal && this.selectedMachineItem.machineId) {
					this.getMachineDetailRequest();
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.slot-content {
		width: 100%;

		.form-label {
			color: #808695;
			font-size: 26rpx;
			padding-right: 8rpx;
			white-space: nowrap;
		}

		.form-val {
			font-size: 26rpx;
			white-space: nowrap;
			color: #515a6e;
		}
	}
</style>
